package com.huangc.cn.rainbow.engine;

import com.huangc.cn.rainbow.task.UploadTask;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author huangc
 */
public class DataTaskEngine {

    private ThreadPoolExecutor executor = new ThreadPoolExecutor(10, 10, 20, TimeUnit.MINUTES, new ArrayBlockingQueue<>(40), new ThreadPoolExecutor.CallerRunsPolicy());

    public void execute(UploadTask task) {
        executor.execute(task);
    }

    public static class DataTaskEngineFactory {

        private static final DataTaskEngine INSTANCE = new DataTaskEngine();

        public static DataTaskEngine getInstance() {
            return INSTANCE;
        }
    }
}
